using System;
using System.Collections.Generic;

namespace SY.Uap.Entity
{
	/// <summary>
	///	
	/// </summary>
	[Serializable]
	public class User
	{
		public const string RESERVE_CONST = "UC_User";
			
		#region Private Members
		private int _userId; 
		private long _jobNumber; 
		private string _userName; 
		private int _deptId; 
		private string _deptName; 
		private string _password; 
		private string _jobName; 
		private int _gender; 
		private long _phone; 
		private string _email; 
		private DateTime _createTime; 
		private int _createBy; 
		private DateTime _lastLoginTime; 
		private int _status;
        private int _userType;
		[NonSerialized]
        private string _reserve;
		#endregion
		
		#region Default ( Empty ) Class Constuctor
		/// <summary>
		/// default constructor
		/// </summary>
		public User()
		{
			_userId = 0; 
			_jobNumber = 0; 
			_userName = null; 
			_deptId = 0; 
			_deptName = null; 
			_password = null; 
			_jobName = null; 
			_gender = 0; 
			_phone = 0; 
			_email = null; 
			_createTime = new DateTime(); 
			_createBy = 0; 
			_lastLoginTime = new DateTime(); 
			_status = 0;
            _userType = 0;
		}
		#endregion // End of Default ( Empty ) Class Constuctor
		
		public Dictionary<string, object> ToDictionary()
		{
			Dictionary<string, object> dictionary = new Dictionary<string, object>();
		
			dictionary.Add("UserId",_userId);
			dictionary.Add("JobNumber",_jobNumber);
			dictionary.Add("UserName",_userName);
			dictionary.Add("DeptId",_deptId);
			dictionary.Add("DeptName",_deptName);
			dictionary.Add("Password",_password);
			dictionary.Add("JobName",_jobName);
			dictionary.Add("Gender",_gender);
			dictionary.Add("Phone",_phone);
			dictionary.Add("Email",_email);
			dictionary.Add("CreateTime",_createTime);
			dictionary.Add("CreateBy",_createBy);
			dictionary.Add("LastLoginTime",_lastLoginTime);
            dictionary.Add("Status", _status);
            dictionary.Add("UserType", _userType);
			
			dictionary.Add("Reserve",Reserve);//特殊
			return dictionary;
		}
		
		#region Public Properties
		/// <summary>
		/// 
		/// </summary>		
		public int UserId
		{
			get { return _userId; }
			set { _userId = value; }
		}
			
		/// <summary>
		/// 
		/// </summary>		
		public long JobNumber
		{
			get { return _jobNumber; }
			set { _jobNumber = value; }
		}
			
		/// <summary>
		/// 
		/// </summary>		
		public string UserName
		{
			get { return _userName; }
			set	
			{
				if( value!= null && value.Length > 16)
					throw new ArgumentOutOfRangeException(@"Invalid value for UserName", value, value);
				
				_userName = value;
			}
		}
			
		/// <summary>
		/// 
		/// </summary>		
		public int DeptId
		{
			get { return _deptId; }
			set { _deptId = value; }
		}
			
		/// <summary>
		/// 
		/// </summary>		
		public string DeptName
		{
			get { return _deptName; }
			set	
			{
				if( value!= null && value.Length > 50)
					throw new ArgumentOutOfRangeException(@"Invalid value for DeptName", value, value);
				
				_deptName = value;
			}
		}
			
		/// <summary>
		/// 
		/// </summary>		
		public string Password
		{
			get { return _password; }
			set	
			{
				if( value!= null && value.Length > 64)
					throw new ArgumentOutOfRangeException(@"Invalid value for Password", value, value);
				
				_password = value;
			}
		}
			
		/// <summary>
		/// 
		/// </summary>		
		public string JobName
		{
			get { return _jobName; }
			set	
			{
				if( value!= null && value.Length > 50)
					throw new ArgumentOutOfRangeException(@"Invalid value for JobName", value, value);
				
				_jobName = value;
			}
		}
			
		/// <summary>
		/// 
		/// </summary>		
		public int Gender
		{
			get { return _gender; }
			set { _gender = value; }
		}
			
		/// <summary>
		/// 
		/// </summary>		
		public long Phone
		{
			get { return _phone; }
			set { _phone = value; }
		}
			
		/// <summary>
		/// 
		/// </summary>		
		public string Email
		{
			get { return _email; }
			set	
			{
				if( value!= null && value.Length > 100)
					throw new ArgumentOutOfRangeException(@"Invalid value for Email", value, value);
				
				_email = value;
			}
		}
			
		/// <summary>
		/// 
		/// </summary>		
		public DateTime CreateTime
		{
			get { return _createTime; }
			set { _createTime = value; }
		}
			
		/// <summary>
		/// 
		/// </summary>		
		public int CreateBy
		{
			get { return _createBy; }
			set { _createBy = value; }
		}
			
		/// <summary>
		/// 
		/// </summary>		
		public DateTime LastLoginTime
		{
			get { return _lastLoginTime; }
			set { _lastLoginTime = value; }
		}
			
		/// <summary>
		/// 
		/// </summary>		
		public int Status
		{
			get { return _status; }
			set { _status = value; }
		}

        public int UserType {
            get { return _userType; }
            set { _userType = value; }
        }
			
		/// <summary>
        /// 保留属性
        /// </summary>
        public string Reserve
        {
            get 
            {
                if (string.IsNullOrEmpty(_reserve))
                    return RESERVE_CONST  ;

                return _reserve; 
            }
            set { _reserve = value; }
        }
		#endregion 

        /// <summary>
        /// 
        /// </summary>
        /// <param name="entry"></param>
        public void Set(User entry)
        {
            if (entry == null) return;

            _userId = entry.UserId;
            _jobNumber = entry.JobNumber;
            _userName = entry.UserName;
            _deptId = entry.DeptId;
            _deptName = entry.DeptName;
            _password = entry.Password;
            _jobName = entry.JobName;
            _gender = entry.Gender;
            _phone = entry.Phone;
            _email = entry.Email;
            _createTime = entry.CreateTime;
            _createBy = entry.CreateBy;
            _lastLoginTime = entry.LastLoginTime;
            _status = entry.Status;
            _userType = entry.UserType;
        }

        public User(User user) {
            Set(user);
        }
	}
}
